/**
 * Created By zhangQ 2018/3/7
 */
import axiosUtils from '@api/env/axiosEnv'

let customAxios = axiosUtils._initAxios()

export function getPowerStockList (param) {
  let data = {
    page: param.page,
    stockStartTime: param.stockStartTime,
    stockEndTime: param.stockEndTime,
    userName: param.userName
  }
  if (param.pageSize) {
    data.pageSize = param.pageSize
  }
  return customAxios({
    url: '/main/powerStock/getPowerStockList',
    method: 'post',
    data: data
  })
}

export function addPowerStock (param) {
  return customAxios({
    url: '/main/powerStock/addPowerStock',
    method: 'post',
    data: {
      stockTime: param.stockTime,
      yesterdayStock: param.yesterdayStock,
      yesterdayArrive: param.yesterdayArrive,
      yesterdayConsume: param.yesterdayConsume,
      nowStock: param.nowStock,
      userName: param.userName,
      userId: param.userId,
      lastQuarterDemand: param.lastQuarterDemand,
      nextQuarterDemand: param.nextQuarterDemand
    }
  })
}

export function getPowerStockInfo (param) {
  return customAxios({
    url: '/main/powerStock/getPowerStockInfo',
    method: 'post',
    data: {
      id: param.id
    }
  })
}

export function editPowerStock (param) {
  return customAxios({
    url: '/main/powerStock/editPowerStock',
    method: 'post',
    data: {
      id: param.id,
      stockTime: param.stockTime,
      yesterdayStock: param.yesterdayStock,
      yesterdayArrive: param.yesterdayArrive,
      yesterdayConsume: param.yesterdayConsume,
      nowStock: param.nowStock,
      userName: param.userName
    }
  })
}

export function getPowerUserList () {
  return customAxios({
    url: '/main/powerStock/getPowerUserList',
    method: 'post'
  })
}

export function getPowerStockByDate (param) {
  return customAxios({
    url: '/main/powerStock/getPowerStockByDate',
    method: 'post',
    data: {
      stockTime: param.stockTime,
      userName: param.userName
    }
  })
}
